package com.jule.miaozhuapc.service.impl;

import java.util.Date;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jule.miaozhuapc.dao.UserLocationDao;
import com.jule.miaozhuapc.domain.WawaUserLocation;
import com.jule.miaozhuapc.req.dto.Location;
import com.jule.miaozhuapc.service.UserLocationService;

@Service
@Transactional
public class UserLocationServiceImpl implements UserLocationService{

	@Autowired
	UserLocationDao userLocationDao;
	@Override
	public void updateLocation(Location location) {
		WawaUserLocation userLocation = new WawaUserLocation();
		userLocation.setAddTime(new Date());
		userLocation.setDetail(location.getDetail());
		userLocation.setId(location.getLocationId());
		userLocation.setLocation(location.getLocation());
		userLocation.setName(location.getName());
		userLocation.setStreet(location.getStreet());
		userLocation.setIsDelete(location.getIsDelete());
		userLocation.setPhone(location.getPhone());
		userLocation.setUserId(location.getUserId());
		userLocationDao.update(userLocation);
	}

	@Override
	public WawaUserLocation findByUserId(Long userId) {
		WawaUserLocation userLocation = null;

		userLocation = userLocationDao.findByUserId(userId);
		return userLocation;

	}
}
